package be.ipl.eBar.domaine;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

@SuppressWarnings("serial")
@Entity
@Table(name="BRASSERIES", schema="EBAR")
public class Brasserie implements Serializable {

	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	private int id;
	@NotNull
	@Column(unique=true)
	private String nom;
	@Embedded
	private Adresse adresse = new Adresse();
	
	protected Brasserie() {}
	
	public Brasserie(String nom, String rueNumero, String codePostal, String commune){
		this.nom = nom;
		this.adresse = new Adresse(rueNumero, codePostal, commune);
	}
	
	public int getId() {
		return id;
	}

	public String getNom() {
		return nom;
	}
	
	public String getRueNumero() {
		return adresse.getRueNumero();
	}
	
	public String getCodePostal() {
		return adresse.getCodePostal();
	}
	
	public String getCommune() {
		return adresse.getCommune();
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + id;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Brasserie other = (Brasserie) obj;
		if (id != other.id)
			return false;
		return true;
	}
	
	
	
}
